function [  ] = setZColName( this, zColId, zColName )
% DataMatrix::setZColName(dataMatrix, zColId, zColName)
% Set col names of the DataMatrix object
% 
% Input
% 1. dataMatrix
% 2. zColId
% 3. zColName
% 
% Output
% 0. 
% 
% Syntax
% ~. dataMatrix.setZColName();
% ~. dataMatrix.setZColName(zColId);
% ~. dataMatrix.setZColName(zColId, zColName);
% 
% Example
% 1. dataMatrix.setZColName(); % Set all col names to be {''}s
% 2. dataMatrix.setZColName(1:2); % Set names of col 1:2 to be {''}s
% 3. dataMatrix.setZColName(1:2, {'c1', 'c2'});
% 4. dataMatrix.setZColName(:, {'c'}); % Set all col names to be {'c_#'}s

%% Check input

if nargin == 1 % If >> dataMatrix.setZColName()
    this.setZColName(':', {''});
    return
end

if nargin == 2 % If >> dataMatrix.setZColName(ZColId)
    if isnumeric(zColId)
        this.setZColName(zColId, {''});
    elseif ischar(zColId{1})
        zColName = zColId;
        this.setZColName(':', zColName);
    end
    return
end

if nargin == 3
    if isequal(zColName, {''})
        if isequal(zColId, ':')
            nColName = this.nCol;
        else
            nColName = length(zColId);
        end
        zColName = repmat({''}, nColName, 1);
    else%if ~isequal(zColName, {''})
        if length(zColName) == 1 ...
                && (length(zColId) > 1 || isequal(zColId, ':'))
            % Generate sequential col names, 
            % e.g., {'c_1', 'c_2', ... , 'c_n'}
            zColName = this.genSeqZColName(zColName{1}, zColId);
        end
    end
end

%% Assign

if isequal(zColId, ':')
    assert(length(zColName) == this.nCol, ...
        'BatErr: Length dismatch: length(zColName) MUST equal $.nCol$.');
    zColId = 1:this.nCol;
else
    assert(length(zColName) == length(zColId), ...
        ['BatErr: Length dismatch: ', ...
        'length(zColName) MUST equal length(zColId).']);
end

this.zColName(1, zColId) = zColName; % Assignment with auto expanding

% Trim the redundant tailing col names
if length(this.zColName) > this.nCol
    this.zColName = this.zColName(1:this.nCol);
end

end
